import { reqCategory, reqBannerList, reqFloorList } from "@/api";
const state = {
    //仓库里面右侧V能瞎书写,看一下服务器返回数据类型
    //商品分类的数据
    category: [],
    //banner轮播图的数据
    bannerList: [],
    //存储floor数据
    floorList: []
};
const mutations = {
    CATEGORYLIST: (state, category) => {
        state.category = category;
    },
    BANNERLIST: (state, bannerList) => {
        state.bannerList = bannerList
    },
    GETFLOORLIST:(state,floorList) =>{
        state.floorList = floorList;
    }
}
const actions = {
    //categoryList类型action
    categoryList: async ({ commit, state, dispatch }) => {
        //书写业务、书写逻辑、书写异步、提交mutation
        let result = await reqCategory();
        //代表服务器返回的数据成功
        if (result.code == 200) {
            commit('CATEGORYLIST', result.data);
        }
    },
    //bannerList类型的action
    bannerList: async ({ commit, state, dispatch }) => {
        let result = await reqBannerList();
        if (result.code == 200) {
            commit('BANNERLIST', result.data)
        }
    },
    //getFloorList类型的action
    getFloorList: async ({ commit, state, dispatch }) => {
        let result = await reqFloorList();
        if (result.code == 200) {
            commit('GETFLOORLIST', result.data);
        }
    }
};
const getters = {};

//默认暴露:小仓库对外暴露的是对象,默认暴露
export default {
    state,
    mutations,
    actions,
    getters
}